package com.roncoo.education.course.service.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.roncoo.education.course.service.dao.UserCourseAppointmentDao;
import com.roncoo.education.course.service.dao.impl.mapper.UserCourseAppointmentMapper;
import com.roncoo.education.course.service.dao.impl.mapper.entity.UserCourseAppointment;
import com.roncoo.education.util.enums.IsSendEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCourseAppointmentDaoImpl implements UserCourseAppointmentDao {

    @Autowired
    private UserCourseAppointmentMapper userCourseAppointmentMapper;

    @Override
    public List<UserCourseAppointment> getByCourseId(Long courseId) {
        QueryWrapper<UserCourseAppointment> eq = new QueryWrapper<UserCourseAppointment>().eq("course_id", courseId).eq("is_send", IsSendEnum.NO.getCode());
        List<UserCourseAppointment> userCourseAppointments = userCourseAppointmentMapper.selectList(eq);
        return userCourseAppointments;
    }

    @Override
    public int updateById(UserCourseAppointment userCourseAppointment) {
        return userCourseAppointmentMapper.updateById(userCourseAppointment);
    }
    public int save(UserCourseAppointment userCourseAppointment) {
        return userCourseAppointmentMapper.insert(userCourseAppointment);
    }

}
